package cn.usian.service.impl;

import cn.usian.common.R;
import cn.usian.dao.DishDao;
import cn.usian.pojo.Dish;
import cn.usian.service.SetmealDishService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SetmealDishServiceImpl implements SetmealDishService {
    @Resource
    private DishDao dishDao;
    @Override
    public R findCategory(Dish dish) {
        LambdaQueryWrapper<Dish> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(dish.getCategoryId()!=null, Dish::getCategoryId,dish.getCategoryId());
        queryWrapper.eq(Dish::getStatus,1);
        queryWrapper.like(dish.getName()!=null, Dish::getName,dish.getName());
        queryWrapper.orderByAsc(Dish::getSort).orderByDesc(Dish::getUpdateTime);

        List<Dish> dishList = dishDao.selectList(queryWrapper);
        return R.success(dishList);

    }
}
